package com.appspot.codelab.docs.client.repository;

public class RepositoryPath {

  private String path;
  private String directoryPath, fileName;
  
  public RepositoryPath(String path) {
	if (!path.startsWith("/")) {
	  path = "/" + path;
	}
    this.path = path;
    int s = path.lastIndexOf('/');
    if (path.length() == 1) {
      this.fileName = "";
    } else {
      switch (s) {
      case 0:
        this.directoryPath = "/";
        this.fileName = path.substring(1);
        break;
      default:
        this.directoryPath = path.substring(0, s);
        this.fileName = path.substring(s + 1);
        break;	
      }
    }
    if (!this.directoryPath.endsWith("/")) {
      this.directoryPath += "/";
    }
  }

  public String getDirectoryPath() {
    return directoryPath;
  }

  public void setDirectoryPath(String directoryPath) {
    this.directoryPath = directoryPath;
  }

  public String getFileName() {
    return fileName;
  }

  public void setFileName(String fileName) {
    this.fileName = fileName;
  }

  public String getPath() {
    return path;
  }

  public void setPath(String path) {
   this.path = path;
  } 
  
}
